#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

#define FILE_NAME(number) "gout.txt"#number
int main()
{
printf("stdin->fd:%d\n",stdin->_fileno);
printf("stdout->fd:%d\n",stdout->_fileno);
printf("stderr->fd:%d\n",stderr->_fileno);
  int fd0 =open(FILE_NAME(1),O_CREAT|O_WRONLY|O_TRUNC,0666);
  int fd1 =open(FILE_NAME(2),O_CREAT|O_WRONLY|O_TRUNC,0666);
  int fd2 =open(FILE_NAME(3),O_CREAT|O_WRONLY|O_TRUNC,0666);
  int fd3 =open(FILE_NAME(4),O_CREAT|O_WRONLY|O_TRUNC,0666);
  int fd4 =open(FILE_NAME(5),O_CREAT|O_WRONLY|O_TRUNC,0666);


printf("fd:%d\n",fd0);
printf("fd:%d\n",fd1);
printf("fd:%d\n",fd2);
printf("fd:%d\n",fd3);
printf("fd:%d\n",fd4);



close(fd0);
close(fd1);
close(fd2);
close(fd3);
close(fd4);




 // umask(0);
//  int fd =open(FILE_NAME,O_CREAT|O_WRONLY|O_TRUNC,0666);
//  int fd =open(FILE_NAME,O_CREAT);
//  if(fd<0)
//{
//  perror("open fail");
//  return 1;
//}
//
//char buffo[256];
//ssize_t num=read(fd,buffo,sizeof(buffo)-1);
//if(num>0) buffo[num]=0;
//printf("%s",buffo);
//
//
////char buddu[64];
////int num=3;
////while(num)
////{
////  sprintf(buddu,"%s:%d\n","aab",num--);
////  write(fd,buddu,strlen(buddu));
////}
////
  return 0;
}


















//#define ONE (0x1)
//#define TWO (0x2)
//#define THREE (0x4)
//#define FOUR (0x8)

//#define ONE (1<<0)
//#define TWO (1<<1)
//#define THREE (1<<2)
//#define FOUR (1<<3)
//
//void show(int flags)
//{
//  if(flags&ONE) printf("one\n");
//  if(flags&TWO) printf("two\n");
//  if(flags&THREE) printf("three\n");
//  if(flags&FOUR) printf("four\n");
//
//}
//
//int main()
//{
//show(ONE);
//show(TWO|THREE);
//show(THREE);
//show(FOUR|ONE|TWO|FOUR);
//
//  return 0;
//}
